package com.example.petplanet.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.time.LocalDateTime;


@Data
public class Message {
    public enum Type {
        TEXT, EMOTION, FILE,LIKE_COMMENT,LIKE_CONTENT, COMMENT, FOLLOW,BOOKMARK
    }

    @JsonIgnore
    private long id;
    private long toUserId;
    private boolean isSystem;
    private long fromUserId;
    private Object message;// 如果是系统消息是数组
    private LocalDateTime createdAt;
    private Type type;

    public Message(long toUserId, boolean isSystem, long fromUserId, Object message, LocalDateTime createdAt, Type type) {
        this.toUserId = toUserId;
        this.isSystem = isSystem;
        this.fromUserId = fromUserId;
        this.message = message;
        this.createdAt = createdAt;
        this.type = type;
    }


    public Message(long id,long toUserId, boolean isSystem, long fromUserId, Object message, LocalDateTime createdAt, Type type) {
        this.id = id;
        this.toUserId = toUserId;
        this.isSystem = isSystem;
        this.fromUserId = fromUserId;
        this.message = message;
        this.createdAt = createdAt;
        this.type = type;
    }

    @Override
    public String toString() {
        return "Message{" +
                "id=" + id +
                ", toUserId=" + toUserId +
                ", isSystem=" + isSystem +
                ", fromUserId=" + fromUserId +
                ", message=" + message +
                ", createdAt=" + createdAt +
                ", type=" + type +
                '}';
    }

//    public static void main(String[] args) {
//       Message message = new Message(1,false,2,"",LocalDateTime.now(),Type.TEXT);
//        String s = JSON.toJSONString(message);
//        Object parse = JSON.parse(s);
//        System.out.println("parse:"+parse);
//        System.out.println(s);
//
//    }
}
